package com.monster.security.handler;

import com.monster.security.utils.SecurityUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 登出成功的处理逻辑
 *
 * @author kuangxz
 * @version 1.0
 * @date 2021/2/5 17:36
 */
@Component
public class MonsterLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        // 查询配置的首页位置

        // 回写成功代码
        SecurityUtils.writerResponseData(response, String.valueOf(HttpServletResponse.SC_OK),null, "退出成功!", true);
    }
}
